class_name GameStateKickoff
extends GameState

var valide_control_schemes := []

func _enter_tree() -> void:
	var country_starting := state_data.country_scored_on
	if country_starting.is_empty():
		country_starting = manager.current_match.country_home
	if country_starting == manager.current_match.country_home:
		valide_control_schemes.append(Player.ControlScheme.P1)
	if country_starting == manager.current_match.country_away and not manager.is_single_player():
		valide_control_schemes.append(Player.ControlScheme.P2)
	if valide_control_schemes.size() == 0:
		valide_control_schemes.append(Player.ControlScheme.P1)
		
func _process(_delta: float) -> void:
	for control_scheme : Player.ControlScheme in valide_control_schemes:
		if KeyUtils.is_action_just_pressed(control_scheme, KeyUtils.Action.PASS):
			GameEvent.kickoff_started()
			SoundPlayer.play(SoundPlayer.Sound.WHISTLE)
			state_transition(GameManager.State.IN_PLAY)
